Skip to content

fix: keep replies to flagged comments, page domain feeds fully, and four smaller fixes - #318

Merged
therealsama merged 6 commits into
mainfrom
fix/comment-gaps-domain-paging-and-view-marks
Nov 2, 2026
Merged

therealsama merged 6 commits into
mainfrom
fix/comment-gaps-domain-paging-and-view-marks

Conversation

@therealsama

@therealsama therealsama commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes six bugs. Each new test that checks a fix fails on the unfixed code.

Bug fixes

  • Replies to a flagged or deleted comment were missing from the thread. Algolia's comment search leaves out flagged and deleted comments but keeps their replies, and buildCommentTree dropped those replies as orphans. The thread now reads the missing parents (and their parents, when also missing) from Firebase. It shows them the way HN does: a [flagged] row with author and time, or a [deleted] row, with the replies under it. Firebase still has the text of older killed comments (2018 and before in the ones checked), so a killed comment always shows [flagged], as HN does. The extra Firebase reads only happen when a parent is missing. They also bring back the few live comments that both Algolia sources miss, when those have replies. On story 50299427, the thread now shows all 14 comments HN shows, in HN's order. Before, a flagged comment and its 5 replies were missing.
  • A domain feed stopped early. A query search can stop counting and return an estimated nbHits (exhaustiveNbHits: false). For dev.to it reported 150 hits over 3 pages, so the feed ended after about 150 stories. When the count is an estimate and the last page was full, paging now continues from the oldest story so far, the same way it already gets past the 1,000-hit cap. /from/dev.to now keeps loading past 290 stories.
  • Opening a flagged or deleted comment showed "Failed to load comment". Algolia's /items returns 404 for those. The comment view now falls back to Firebase for the comment and gets each reply from Algolia, through a new fetchCommentItem(). Other Algolia errors are still errors. fetchAlgoliaItem now throws NotFoundError on a 404. The desktop page of a deleted comment shows [deleted] where the author goes, instead of "unknown" over an empty body. The desktop page first shows the copy of the comment it already read from Firebase. That copy now says [flagged] too, so a killed comment's text doesn't show while the page loads or after its request fails.
  • Coming back to a phone's swipe feed marked its top story as viewed. A restore or Back mounts the swipe viewer at index 0 and jumps to the saved story before paint. The dwell effect still ran for index 0, so the top story was hidden for 12 hours without being seen. The viewer now skips marking until it reaches the story it's jumping to.
  • Counts of one said "1 points" and "1 comments". This was in story cards and the story header. They now say "1 point" and "1 comment".
  • Items 360–364 days old said "12 months ago". formatTimeAgo counts 30-day months, which reach 12 five days before a year. It now stays at "11 months ago" until "1 year ago".

Known limitations

  • On a phone, opening a deleted comment shows "Comment deleted" without its replies. Desktop shows them under the [deleted] header.
  • In threads over 1,000 comments, replies to a flagged or deleted comment usually stay missing. Search returns at most 1,000 comments, and Algolia's item tree, which fills in the rest, leaves out flagged and deleted comments along with their replies. A missing parent is only read from Firebase when search returned one of its replies. In 41002195 (3,859 comments) and 38309611 (2,530 comments), none of the 9 flagged or deleted top-level comments with replies came back, and neither did their 13 direct replies. Finding them would mean checking the Firebase kids lists for ids neither Algolia source has, which is left for a follow-up.
  • In the comment view, a flagged or deleted reply further down the tree is still left out with its replies, because Algolia's item tree omits them. Only the opened comment comes from Firebase.
  • A flagged comment with no live replies has no story link in the comment view, because the story id comes from a reply.

Algolia's comment search leaves out flagged and deleted comments but
returns their replies, and buildCommentTree dropped any reply whose
parent wasn't in the results, on the premise that HN hides the subtree
under a dead comment. It doesn't: HN shows the flagged comment as a
[flagged] row and keeps its replies, collapsed. Story 50299427 had 11
comments and showed 6; 5 of the top 14 stories were missing replies,
including moderator replies.

The tree now reads each missing parent from Firebase, and its parent
when that is missing too, and puts it in the thread. A flagged comment
shows its author, time and [flagged], as on HN. Firebase still has the
original text of older killed comments (2018 and before in the ones
checked), so that text is replaced. A deleted one shows as a [deleted]
row through a new `deleted` flag on Comment. Replies whose parent
Firebase doesn't have either are still dropped.

The batched Firebase read in fetchKidsOrdering moves to a shared
readItemsBatched, and a placeholder's kids order comes with it, so its
replies keep HN's order without a second read.
A domain feed is a query search on the URL, and Algolia can stop
counting a query early: for dev.to it reports nbHits 150 with
exhaustiveNbHits false, returns 3 full pages of 50, and nothing past
them. nextAlgoliaPage only started over from the oldest hit when nbHits
went past the 1,000-hit cap, so /from/dev.to ended after 147 stories
from 2021 while a search from the oldest one finds about 6,500 more.

It now also starts over when the count is an estimate and the last
page came back full. A short page still ends the feed.
The comment swiper's panels come from parent.kids in Firebase, which
lists flagged and deleted comments, and each panel loads from Algolia's
/items, which 404s them. Swiping onto one showed "Failed to load
comment" with a Retry that could never work. On the largest current
thread, 35 of 243 top-level comments are flagged or deleted, and every
story checked had some. A permalink to one failed the same way.

fetchAlgoliaItem now throws NotFoundError on a 404, and the comment
pages load through a new fetchCommentItem, which reads a comment Algolia
doesn't have from Firebase and its live replies from Algolia. A flagged
comment shows its author and [flagged] with its replies, as on HN, even
when Firebase still has its original text. On a phone a deleted one
shows the existing "Comment deleted" state; on desktop it shows
[deleted] where the author goes, with its replies, instead of "unknown"
over an empty body. Other Algolia errors still show the error and its
Retry.

The desktop page first shows the copy of the comment it already read
from Firebase, and keeps it if its own request fails, so that copy
shows [flagged] too.
…er one

A restore or Back mounts the swipe viewer on index 0 and jumps to its story
in a layout effect, before paint. The dwell effect for index 0 still ran, so
the top story got hidden for 12 hours without being seen.
@therealsama
therealsama force-pushed the fix/comment-gaps-domain-paging-and-view-marks branch from 43b6dab to e47b2f8 Compare November 2, 2026 02:11
@therealsama
therealsama enabled auto-merge November 2, 2026 09:10
@therealsama
therealsama merged commit f3b6d60 into main Nov 2, 2026
4 checks passed
@therealsama
therealsama deleted the fix/comment-gaps-domain-paging-and-view-marks branch November 2, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants